const {query}= require('../util/query')
/*
设置图片标签
 */
let setTag=async function(tagInfo){
  let _sql =
    `INSERT INTO USER_IMAGES set ?;`
  return await query(_sql, tagInfo)
}
/*
移除图片标签
 */
let removeTag=async function(user,fileName,tag){
  let _sql =`
    DELETE FROM USER_IMAGES WHERE USER_ID='${user}' and IMG_NAME='${fileName}' and TAG='${tag}'
    `
  return await query(_sql)
}
/*
获取图片标签
 */
let getTagList=async function(user,fileName){
  let _sql =`
    SELECT * FROM USER_IMAGES WHERE USER_ID='${user}' and IMG_NAME='${fileName}'
    `
  return await query(_sql)
}
/*
获取所有标签
 */
let getAllTagList=async function(user){
  let _sql =`
    SELECT * FROM USER_IMAGES WHERE USER_ID='${user}'
    `
  return await query(_sql)
}
module.exports={
  setTag,
  removeTag,
  getTagList,
  getAllTagList
}
